package archer.application.core.entity.system;

import archer.application.core.entity.user.Staff;
import archer.framework.common.entity.BaseEntity;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author christ
 * @date 2016/6/7
 */
@Entity
public class UserRoleRel extends BaseEntity {

    public static final Find<UserRoleRel> find = new Find<UserRoleRel>(UserRoleRel.class);

    @ManyToOne
    @JoinColumn(name = "user_id")
    private Staff staff;

    @ManyToOne
    @JoinColumn(name = "role_id")
    private Role role;

    public Staff getStaff() {
        return staff;
    }

    public UserRoleRel setStaff(Staff staff) {
        this.staff = staff;
        return this;
    }

    public Role getRole() {
        return role;
    }

    public UserRoleRel setRole(Role role) {
        this.role = role;
        return this;
    }

    public String getUserId() {
        if (this.staff == null) {
            this.staff = new Staff();
        }
        return this.staff.getId();
    }

    public UserRoleRel setUserId(String userId) {
        if (this.staff == null) {
            this.staff = new Staff();
        }
        this.staff.setId(userId);
        return this;
    }

    public String getRoleId() {
        if (this.role == null) {
            this.role = new Role();
        }
        return this.role.getId();
    }

    public UserRoleRel setRoleId(String roleId) {
        if (this.role == null) {
            this.role = new Role();
        }
        this.role.setId(roleId);
        return this;
    }
}
